#ifndef __LOGIC_H__
#define __LOGIC_H__

#include <functional>
#include <memory>
#include <map>

class HttpConnection;
using HttpHandler = std::function<void(std::shared_ptr<HttpConnection>)>;


class Logic
{
public:
    Logic();

    // 处理 Get 请求任务
    bool HandleGet(std::string url, std::shared_ptr<HttpConnection> conn);
    // 添加 Get 请求任务
    void RegisterGet(const std::string& url, HttpHandler cb);

    // 处理 Post 请求任务
    bool HandlePost(std::string url, std::shared_ptr<HttpConnection> conn);
    // 添加 Post 请求任务
    void RegisterPost(const std::string& url, HttpHandler cb);

private:
    void _SetCallBack();

private:
    std::map<std::string, HttpHandler> _post_handlers;
    std::map<std::string, HttpHandler> _get_handlers;
};


// 获取验证码
void getVerificationCode(std::shared_ptr<HttpConnection> conn);
// 用户注册
void userRegister(std::shared_ptr<HttpConnection> conn);
// 修改密码
void modifyPassword(std::shared_ptr<HttpConnection> conn);
// 用户登录
void userLogin(std::shared_ptr<HttpConnection> conn);


#endif // !__LOGIC_H__